home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 24 / 024.d81 / t.perfect input < prev    next >
Text File  |  2022-08-26  |  6KB  |  424 lines

  1.  
  2.             PERFECT INPUT
  3.                  by
  4.         Bennett Cookson, Jr.
  5.  
  6.  
  7. COMMODORE MICROCOMPUTERS MAGAZINE
  8. May/June, 1986
  9. p. 103
  10.  
  11.  
  12.   PERFECT INPUT adds commands to BASIC
  13.  
  14. that help overcome the INPUT
  15.  
  16. statement's limitations.  By running
  17.  
  18. this program before you write your
  19.  
  20. programs, you will be able to use
  21.  
  22. commas and colons in your statements,
  23.  
  24. to redefine the keyboard, and to have
  25.  
  26. full cursor movement within a set
  27.  
  28. range.  And those are just SOME of
  29.  
  30. the features of PERFECT INPUT.
  31.  
  32.  
  33.   Keep in mind that if you do write a
  34.  
  35. program using the PERFECT INPUT
  36.  
  37. commands, you must always load and run
  38.  
  39. PERFECT INPUT before you run a program
  40.  
  41. that uses its commands.
  42.  
  43.  
  44. PERFECT INPUT COMMANDS
  45.  
  46.  
  47. INPUT A$
  48.  
  49. INPUT"PROMPT";B$
  50.  
  51.  
  52.   When the PERFECT INPUT statement is
  53.  
  54. used normally, the "?" prompt is gone.
  55.  
  56. Commas and colons that would normally
  57.  
  58. elicit an ?EXTRA IGNORED message are
  59.  
  60. accepted like any other character.
  61.  
  62. Note that commas and colons are
  63.  
  64. accepted only into string variables,
  65.  
  66. not numeric variables.  This means
  67.  
  68. that you cannot use "INPUT A,B", but
  69.  
  70. you can use "INPUT A$,B$" to input
  71.  
  72. numbers.
  73.  
  74.  
  75.   Also, cursor movement is limited to
  76.  
  77. a 79-character range.  The user still
  78.  
  79. has full cursor movement, but the
  80.  
  81. cursor seems to hit a barrier before
  82.  
  83. it gets out of range.
  84.  
  85.  
  86. INPUT\10,A$
  87.  
  88. INPUT\20,"PROMPT",X$
  89.  
  90.  
  91.   This syntax allows the programmer to
  92.  
  93. control the number of characters a
  94.  
  95. user can type in by setting the
  96.  
  97. cursor range.  Putting the English
  98.  
  99. pound sign before the line number
  100.  
  101. will cause it to be read as "limit".
  102.  
  103. The limit can range from 1 to 79;
  104.  
  105. anything larger will cause an ILLEGAL
  106.  
  107. QUANTITY error.
  108.  
  109.  
  110. INPUT 200,A$
  111.  
  112.  
  113.   This syntax provides an exit from
  114.  
  115. INPUT.  When the user presses
  116.  
  117. a certain key (definable to any key),
  118.  
  119. BASIC will GOTO the line specified in
  120.  
  121. the INPUT statement.  (The "certain
  122.  
  123. key" is defined by the DEFine command,
  124.  
  125. which will be explained later.)  With
  126.  
  127. this command, for example, your
  128.  
  129. program's user could escape from an
  130.  
  131. INPUT and go back to a menu without
  132.  
  133. affecting any variables.
  134.  
  135.  
  136. INPUT 15,400,"PROMPT";N
  137.  
  138.  
  139.   The above features can be used
  140.  
  141. together.  The limit comes first, then
  142.  
  143. the exit line number.  If there is a
  144.  
  145. prompt string, it always comes last,
  146.  
  147. just before the variable.
  148.  
  149.  
  150. AT x,y
  151.  
  152.  
  153.  The AT command allows you to
  154.  
  155. position the cursor anywhere on the
  156.  
  157. screen by giving the X and Y
  158.  
  159. coordinates.  X represents the
  160.  
  161. horizontal position (0-39), Y the
  162.  
  163. vertical position (0-24).  The values
  164.  
  165. for X and Y may be expressed in any
  166.  
  167. form.  These are some examples of how
  168.  
  169. the AT command is used:
  170.  
  171.  
  172. AT 5,7:PRINT"position 5,7"
  173.  
  174. AT X,Y:INPUT B$
  175.  
  176. AT J-5+G,INT(W):PRINT" x marks the
  177.  
  178. spot"
  179.  
  180. -------
  181.  
  182.  
  183. THE DEFine COMMAND
  184.  
  185.  
  186.   The DEF key command allows you to
  187.  
  188. redefine any of the keys except the
  189.  
  190. SHIFT, CONTROL, COMMODORE, RUN/STOP,
  191.  
  192. and RESTORE keys.  For example,
  193.  
  194.  
  195. DEF"A=B,R=13,133=F"
  196.  
  197.  
  198. changes the "A" key to "B", the "R"
  199.  
  200. key to CHR$(13), and CHR$(133) to "F".
  201.  
  202. Because the DEFine key routine works
  203.  
  204. deep inside the operating system, if
  205.  
  206. you changed "R" to CHR$(13) (RETURN),
  207.  
  208. R would act like the RETURN key in all
  209.  
  210. cases.
  211.  
  212.  
  213.   The DEFinition list must be written
  214.  
  215. as a string in quotes or a string
  216.  
  217. variable.  All characters except
  218.  
  219. numbers, apostrophes, and back arrows
  220.  
  221. are considered literally as the
  222.  
  223. character to DEFine.
  224.  
  225.  
  226.   Numbers, however, are considered
  227.  
  228. ASCII values and to specify a number
  229.  
  230. as a literal character you must place
  231.  
  232. an apostrophe just before it.  For
  233.  
  234. example, 5 would mean CHR$(5), while
  235.  
  236. '5 means the character "5".
  237.  
  238.  
  239.   A range of characters can be used
  240.  
  241. with this command.  For example:
  242.  
  243.  
  244. DEF"91-255=0"
  245.  
  246.  
  247. will set all characters with an ASCII
  248.  
  249. value of 91 through 255 to zero,
  250.  
  251. thereby disabling all of those keys.
  252.  
  253. You would use a command like this if
  254.  
  255. you wanted to disable all graphics
  256.  
  257. keys.
  258.  
  259.  
  260.   Another form of the command can
  261.  
  262. look like this:
  263.  
  264.  
  265. DEF"1-255=0,A-Z=_"
  266.  
  267.  
  268. The first part of this line disables
  269.  
  270. all keys; the second part restores
  271.  
  272. the A to Z keys to normal.  The left
  273.  
  274. arrow key means "restore to normal".
  275.  
  276.  
  277.   The escape key that exits from an
  278.  
  279. INPUT statement can be any key defined
  280.  
  281. as CHR$(1).  For example,
  282.  
  283.  
  284. DEF"133=1"
  285.  
  286.  
  287. will define F1 as the escape key.
  288.  
  289. Also, any key defined as CHR$(2) will
  290.  
  291. act as an erase key, which erases the
  292.  
  293. character under the cursor.
  294.  
  295.  
  296.   The DEF command by itself will
  297.  
  298. reset the keyboard to normal.
  299.  
  300. RUN/STOP-RESTORE will also reset the
  301.  
  302. keyboard, but will not disable the
  303.  
  304. DEFine key or other commands.  As an
  305.  
  306. added feature,the keyboard can also
  307.  
  308. be reset with the END command or if an
  309.  
  310. error occurs in the program-- making
  311.  
  312. it easier to edit lines.  If you do
  313.  
  314. not want the keyboard to reset, you
  315.  
  316. can remove the two relevant lines
  317.  
  318. from the loader program with REMs that
  319.  
  320. say "reset if error" and "reset if
  321.  
  322. end".
  323.  
  324.  
  325. DEMO PROGRAM
  326.  
  327.  
  328.   Cookson has added a demo program
  329.  
  330. that shows some of PERFECT INPUT's
  331.  
  332. features.  Before running the demo,
  333.  
  334. first load and run PERFECT INPUT, then
  335.  
  336. load and run the demo program.
  337.  
  338.  
  339.   Lines 70-86 show how to create and
  340.  
  341. combine present strings.  For example,
  342.  
  343. once you have set NUMKEY$ to define a
  344.  
  345. numeric keypad (line 80), you can use
  346.  
  347. DEF NUMKEY$, which is easier than
  348.  
  349. defining keys one by one. In line 72,
  350.  
  351. NOKEY$ will disable all keys.  With
  352.  
  353. this method, you can disable all keys
  354.  
  355. and then activate only the keys you
  356.  
  357. want.  Also, notice how the comma is
  358.  
  359. used in line 80 when linking strings.
  360.  
  361.  
  362.    Lines 100-150 print a box on the
  363.  
  364. screen and allow the user to fill in
  365.  
  366. the box, but not move the cursor out
  367.  
  368. of the box.  Notice that the DELETE
  369.  
  370. key has been disabled.  Also, it is a
  371.  
  372. good idea to disable the quote mark
  373.  
  374. key, because the quote mode can cause
  375.  
  376. problems in an INPUT statement.
  377.  
  378.  
  379.   Lines 450-460 show that the DEF
  380.  
  381. command can be used easily with the
  382.  
  383. GET statement, and lines 500-680 show
  384.  
  385. that the DEF command makes it easy to
  386.  
  387. use function keys.  Notice that the
  388.  
  389. function keys are converted to numbers
  390.  
  391. that can be used with an ON GOSUB
  392.  
  393. command.  And lines 800-850 show how
  394.  
  395. the escape key can be used to cause
  396.  
  397. BASIC to jump out of an INPUT
  398.  
  399. STATEMENT.
  400.  
  401.  
  402. NOTE: Because of the nature of this
  403. program, it cannot be run from the
  404. Loadstar operating system.  Press
  405. RUN/STOP RESTORE and then type:
  406.  
  407.   LOAD"PERFECT INPUT",8
  408.   RUN
  409.  
  410. Then to run the demo type:
  411.  
  412.   LOAD"INPUT DEMO",8
  413.   RUN
  414.  
  415. Study a listing of the demo to see
  416. how useful PERFECT INPUT can be to
  417. your programs.
  418.  
  419. FILES REQUIRED:
  420.  
  421. PERFECT INPUT     INPUT DEMO
  422.  
  423. ------------<end of text>------------
  424.